// 封装用户相关的接口
import axios from '@/utils/request'
// import store from '@/store'
/**
 * 用户登录
 * @param {Number} mobile 手机号
 * @param {Number} code 验证
 * @returns
 */

export const userLogin = (mobile, code) =>
  axios({
    method: 'POST',
    url: '/v1_0/authorizations',
    data: {
      mobile,
      code
    }
  })

export const getUserInfo = () => {
  // const token = store.state.user.token.token
  // console.log(token)
  return axios({
    method: 'GET',
    url: '/v1_0/user/profile'
    // headers: {
    //   Authorization: 'Bearer ' + token
    // }
  })
}

/**
 * 编辑个人信息
 * @param {*} data 修改的数据
 * @returns
 */
export const editUserInfo = (data) =>
  axios({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })

/**
 * 裁切图片
 * @param {*} fd FormData的实例对象 收集到裁切的图片
 * @returns
 */
export const editUserAvatar = (fd) =>
  axios({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data: fd
  })
